<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>01-组件化</title>
    </head>
    <body>
        <div id="app">
            <button @click="count++">点赞了 {{count}} 次</button>
            <counter></counter>
            <counter></counter>
            <button-counter></button-counter>
        </div>

        <script
            src="../node_modules/vue/dist/vue.min.js"
            type="text/javascript"
        ></script>
        <script>
            Vue.config.devtools = true;
            Vue.component("counter", {
                template: `<button v-on:click="count++">点赞了 {{count}} 次</button>`,
                data() {
                    return {
                        count: 1,
                    };
                },
            });

            new Vue({
                el: "#app",
                data: {
                    count: 1,
                },
                components: {
                    "button-counter": {
                        template: `<button v-on:click="count++" style="background: yellow">点赞了 {{count}} 次</button>`,
                        data() {
                            return {
                                count: 1,
                            };
                        },
                    },
                },
            });
        </script>
    </body>
</html>
